﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[AddComponentMenu("TagMachine/UI/Game/Player Score")]
public class UIPlayerScore : MonoBehaviour
{
	private Text m_TextComponent = null;

	void Start()
	{
		m_TextComponent = GetComponentInChildren< Text >();
	}
	
	// Update is called once per frame
	void Update ()
	{
		string PlayerScores = "";
		if ( GameModeClassic.Instance.IsGameEnded )
		{
			for ( int i = 0; i < GameModeClassic.Instance.NumPlayers; ++i )
			{
				if ( i > 0 )
				{
					PlayerScores += "\n";
				}

				PlayerScores += "Player " + i + " : " + 
								GameModeClassic.Instance.GetPlayerScoreTotal( i );
			}
		}
		else if ( !GameModeClassic.Instance.IsPickingWolf )
		{
			for ( int i = 0; i < GameModeClassic.Instance.NumPlayers; ++i )
			{
				if ( i > 0 )
				{
					PlayerScores += "\n";
				}

				PlayerScores += "Player " + i + " : " + 
								GameModeClassic.Instance.GetPlayerScoreRound( i );
			}			
		}
		else
		{
			PlayerScores = "Picking New Wolf!";
		}

		m_TextComponent.text = PlayerScores;
	}
}
